package com.lpit.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lpit.dto.ArticleHomeDto;
import com.lpit.dto.ArticleManagementDto;
import com.lpit.pojo.Article;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lpit.vo.ArticleManagementVo;
import com.lpit.vo.ArticleVo;
import com.lpit.vo.CommentVo;
import com.lpit.vo.HomePageDataVo;
import com.sun.istack.internal.NotNull;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @author Administrator
* @description 针对表【article(文章表)】的数据库操作Mapper
* @createDate 2023-06-27 14:43:33
* @Entity com.lpit.entity.Article
*/
@Mapper
public interface ArticleMapper extends BaseMapper<Article> {

    List<ArticleHomeDto> selectHomePageDisplay();

    /**根据文章id查询文章的浏览数*/
    Integer selectArticleCommentsByArticleId(Integer articleId);

    /**根据文章id查询文章的评论数*/
    Integer selectArticlePageViewByArticleId(Integer articleId);

    /**根据用户id查询用户文章根据浏览量降序*/
    List<ArticleVo> selectArticlePageViewSortByUserId(Integer userId);

    /**根据用户id查询用户文章，并显示文章的浏览量跟评论量*/
    List<ArticleVo> selectArticlePageViceAndCommentsByUserId(IPage<ArticleVo> articleVoIPage,@NotNull Integer userId);

    /**
     * 根据用户ID，查询用户会喜欢的文章（用户点赞最多文章所在的频道为推荐内容）
     * @param homePageDataVoiPage
     * @param userId
     * @return List<HomePageDataVo>
     */
    List<HomePageDataVo> selectFindArticlesThatUsersWillLike(IPage<HomePageDataVo> homePageDataVoiPage, @NotNull Integer userId);

    /**
     * 文章管理
     * @param page
     * @param
     * @return
     */
    Page<ArticleManagementVo> queryPageByUserId(@Param("page") IPage<ArticleManagementVo> page , @Param("article") ArticleManagementDto article,@Param(Constants.WRAPPER) Wrapper<ArticleManagementVo> wrapper);

    Page<CommentVo> queryPageByUserIdAndComment(@Param("page") IPage<ArticleManagementVo> page , @Param("id") Integer id);
    /**查出文章累计阅读数量*/
    Long sumNumberArticlesRead ();
}




